package My_Stack;

import java.util.LinkedList;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 周斌
 * Date: 2024-03-10
 * Time: 21:45
 */
public class SinglyLinkedStack {
    static class ListNode {
        public int val;
        public ListNode next;
        public ListNode(int val) {
            this.val = val;
        }
    }
    public ListNode head;
    //push
    public void push(int val) {
        ListNode node = new ListNode(val);
        node.next = this.head;
        this.head = node;
    }
    //pop
    public int pop() {
        int ret = head.val;
        this.head = head.next;
        return ret;
    }
    //peek
    public int peek() {
        return head.val;
    }
}
